--[[
Project: HunterRP
File: cl_drawfuncs.lua
Author: Sebihunter, Cypher
]]--

include( "shared.lua" )

function createCharGUI() 
	local model={}

	model[1] = "models/Humans/Group01/male_01.mdl"
	model[2] = "models/Humans/Group01/male_02.mdl"
	model[3] = "models/Humans/Group01/male_03.mdl"
	model[4] = "models/Humans/Group01/male_04.mdl"
	model[5] = "models/Humans/Group01/male_05.mdl"
	model[6] = "models/Humans/Group01/male_06.mdl"
	model[7] = "models/Humans/Group01/male_07.mdl"
	model[8] = "models/Humans/Group01/male_08.mdl"
	model[9] = "models/Humans/Group01/male_09.mdl"

	model[10] = "models/Humans/Group01/Female_01.mdl"
	model[11] = "models/Humans/Group01/Female_02.mdl"
	model[12] = "models/Humans/Group01/Female_03.mdl"
	model[13] = "models/Humans/Group01/Female_04.mdl"
	model[15] = "models/Humans/Group01/Female_06.mdl"
	model[16] = "models/Humans/Group01/Female_07.mdl"	

	local selectionframe = vgui.Create("DFrame")
	local IconList = vgui.Create("DPanelList", selectionframe)

	selectionframe:Center()
	selectionframe:SetSize(400,300)
	selectionframe:SetTitle("Model Selection")
	selectionframe:MakePopup()
	selectionframe:SetDraggable( false ) 
	selectionframe:ShowCloseButton( false ) 

	IconList:EnableVerticalScrollbar(true)
	IconList:EnableHorizontal(true)
	IconList:SetPadding(4)
	IconList:SetPos(10,30)
	IconList:SetSize(380,260)
	selectionframe:Center()

	for k, v in pairs (model) do
		local icon = vgui.Create( "SpawnIcon", IconList ) 
		icon:SetModel( v )
		IconList:AddItem( icon )
		icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("new_player", tostring(model[v])) selectionframe:SetVisible(false) end
	end
end 
concommand.Add( "menu_charcreate", createCharGUI ) 

function changeNameGUI() 

	local selectionframe = vgui.Create("DFrame")
	selectionframe:Center()
	selectionframe:SetSize(200,100)
	selectionframe:SetTitle("Select your Name")
	selectionframe:MakePopup()
	selectionframe:SetDraggable( false ) 
	selectionframe:ShowCloseButton( false ) 
	
	local Label1 = vgui.Create("Label", selectionframe)
	Label1:SetPos(10,30)
	Label1:SetText("Firstname:")
	
	local Label2 = vgui.Create("Label", selectionframe)
	Label2:SetPos(10,50)
	Label2:SetText("Lastname:")	

	local InputDialogF =  vgui.Create( "DTextEntry", selectionframe );
	InputDialogF:SetPos( 90, 34 );
	InputDialogF:SetSize( 100, 15 );
	
	local InputDialogL =  vgui.Create( "DTextEntry", selectionframe );
	InputDialogL:SetPos( 90, 54 );
	InputDialogL:SetSize( 100, 15 );	
	
	selectionframe:Center()

	local button = vgui.Create("Button", selectionframe)
	button:SetPos( 75, 75 );
	button:SetSize( 50,20 )
	button:SetText( "Ok" )

	button.DoClick = function()
		surface.PlaySound( "ui/buttonclickrelease.wav" )
		if (InputDialogF:GetValue() ~= "" and InputDialogL:GetValue() ~= "") and (InputDialogF:GetValue() ~= "Minge" and InputDialogL:GetValue() ~= "Bag") then
			RunConsoleCommand("change_name", InputDialogF:GetValue(), InputDialogL:GetValue()) 
			selectionframe:SetVisible(false)
		end
	end
end 
concommand.Add( "menu_name", changeNameGUI ) 
